package no.uib.hplims.tools.columngenerators;

import no.uib.hplims.models.Peptide;

import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Link;
import com.vaadin.ui.Table;
import com.vaadin.ui.Table.ColumnGenerator;

public class UniProtAccessionColumnGenerator implements ColumnGenerator {
	private static final long serialVersionUID = 5656021998071402197L;

	public Object generateCell(Table source, Object itemId, Object columnId) {
		Peptide p = (Peptide) itemId;
		Link uniProtLink = new Link(
				p.getUniProtAccession(),
				new ExternalResource(
						"http://www.uniprot.org/uniprot/"
								+ p.getUniProtAccession()));
		// Open the URL in a new window/tab
		uniProtLink.setTargetName("_blank");
		return uniProtLink;
	}

}
